﻿using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using yysAuxiliary.FS;

namespace yysAuxiliary
{
    public class PicHandle
    {
        private CancellationToken _cancellationToken;
        public PicHandle(Action<string> action, CancellationToken cancellationToken)
        {
            SendMsg = action;
            _cancellationToken = cancellationToken;
        }

        /// <summary>
        /// 发送消息委托
        /// </summary>
        public Action<string> SendMsg;

        /// <summary>
        /// 执行
        /// </summary>
        public async Task Execute()
        {
            SendMsg($"开始执行");
            while (!_cancellationToken.IsCancellationRequested && Data.isRun)
            {
                BaseFs fs = null;
                switch (Data.IndexFS.fs)
                {
                    case Data.FS.YL:
                        fs = new YL(SendMsg);
                        break;
                    case Data.FS.YH:
                        fs = new YH(SendMsg);
                        break;
                    case Data.FS.JJTP:
                        fs = new JJTP(SendMsg);
                        break;
                    case Data.FS.YYH:
                        fs = new YYH(SendMsg);
                        break;
                }
                await fs.Run();
            }
            SendMsg($"结束执行");
        }
    }


}
